package cn.csc.module.shoppingCard.api.card;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.shoppingCard.api.card.dto.CardMultiLockReqDTO;
import cn.csc.module.shoppingCard.api.card.dto.CardRespDTO;
import cn.csc.module.shoppingCard.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.math.BigInteger;
import java.util.List;

/**
 * 购物卡 feign api
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/11 15:50
 */

@FeignClient(name = ApiConstants.NAME) // TODO fallbackFactory =
@Api(tags = "RPC 服务 - 购物卡")
public interface CardApi {

    String PREFIX = ApiConstants.PREFIX + "/shopping-card";

    /**
     * 获取当前用户的购物卡(可用)
     */
    @GetMapping(PREFIX + "/card/listOfCurrent")
    @ApiOperation("获取当前用户的购物卡")
    CommonResult<List<CardRespDTO>> listOfCurrent();


    /**
     * 锁定购物卡
     */
    @PostMapping(PREFIX + "/card/lock")
    @ApiOperation("锁定购物卡")
    CommonResult<Boolean> lock(@RequestParam("cardId") BigInteger cardId,@RequestParam("orderId") BigInteger orderId);

    /**
     * 锁定购物卡
     */
    @PostMapping(PREFIX + "/card/multiLock")
    @ApiOperation("锁定购物卡")
    CommonResult<Boolean> multiLock(@Valid @RequestBody List<CardMultiLockReqDTO> list);

    /**
     * 解锁购物卡
     * @param orderIds 订单ID
     * @param userId 用户ID
     * @return
     */
    @PostMapping(PREFIX + "/card/unLock")
    @ApiOperation("解锁购物卡")
    CommonResult<Boolean> unLock(@RequestParam("orderIds") List<BigInteger> orderIds, @RequestParam("userId") BigInteger userId);


    /**
     * 根据购物卡Id获取购物卡
     */
    @GetMapping(PREFIX + "/card/listByCardId")
    @ApiOperation("获取当前用户的购物卡")
    CommonResult<List<CardRespDTO>> listByCardId(@RequestParam("cardIds") List<BigInteger> cardIds);
}
